import logging,yagmail
import HTMLTestRunner_cn
class Tools():
    def Log1(self):
        log=logging.basicConfig(level=logging.DEBUG,
                                format='%(levelname)S %(message)S %(filename)S %(asctime)S %(lineno)S ')
        return log
    def Log2(self):
        log2=logging.basicConfig(level=logging.DEBUG,
                                format='%(levelname)s %(message)s %(filename)s %(asctime)s %(lineno)d ',
                                 filename='A3mall.log',
                                 filemode='a+')
        return log2
    def Log3(self):
        logger=logging.getLogger()
        logger.setLevel(logging.INFO)
        ch=logging.StreamHandler()
        ch.setLevel(logging.INFO)
        fmt=logging.Formatter('%(levelname)s %(message)s %(filename)s %(asctime)s %(lineno)d')
        ch.setFormatter(fmt)
        logger.addHandler(ch)
        logger.info('这是一个info')
    def htlm(self):
        report=HTMLTestRunner_cn.HTMLTestRunner(open('a3mall.html','wb')
                                                ,title='测试报告'
                                                ,description='数据驱动')
        return report
    def email(self,file):
        email=yagmail.SMTP(user='2031077871@qq.com',password='knnftuvjposdcjbi',host='smtp.qq.com')
        email.send(to='2031077871@qq.com',subject='测试结果',contents='测试结果',attachments=file)
        email.close()